<template>
  <div class="app-container">
    <el-card shadow="hover">
      <div class="fx-row fx-cen-cen mb20">新增产业资讯</div>
      <el-form ref="form" :model="form" :rules="rules" label-position="right" label-width="100px">
        <el-form-item label="标题" prop="title">
          <el-input v-model="form.title" placeholder="请输入标题"></el-input>
        </el-form-item>
        <el-form-item label="链接" prop="url">
          <el-input v-model="form.url" placeholder="请输入链接"></el-input>
        </el-form-item>
        <el-form-item label="资讯详情" prop="detail">
          <el-input v-model="form.detail" type="textarea" placeholder="请输入资讯详情"></el-input>
        </el-form-item>
        <el-form-item label="发布时间" prop="pub_date">
          <el-date-picker v-model="form.pub_date" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSubmit">新增</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import {AddYuanquNews} from "@/api/upload";

export default {
  name: "industry-news",
  data() {
    return {
      form: {
        title: '',
        url: '',
        detail: '',
        pub_date: ''
      },
      rules: {
        title: [{
          required: true,
          message: '标题必填'
        }],
        pub_date: [{
          required: true,
          message: '发布时间必填'
        }]
      }
    }
  },
  methods: {
    handleSubmit() {
      this.$refs.form.validate().then(() => {
        AddYuanquNews(this.form).then(res => {
          this.msgSuccess(res.result?.message || '保存成功')
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
